#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<unordered_set>
using namespace std;

class Solution{
    public:
    int ans1(string s){
        int length = s.size();
        unordered_set<char> ch;
        int p = 0;
        int len = 0;
        for(int i = 0; i != length; i++){
            if(i != 0){
                ch.erase(s[i-1]);
            }
            int c = ch.count(s[p]);
            while(p < length && !ch.count(s[p])){
                ch.insert(s[p]);
                p++;
            }
            len = max(len, p-i);
        }
        return len;

    }
};

void test1(){
    Solution s;
    string str = "abcabcbb";
    int ret = s.ans1(str);
    cout << ret << endl;

}

void test2(){
    Solution s;
    string str = "bbbbb";
    int ret = s.ans1(str);
    cout << ret << endl;

}

void test3(){
    Solution s;
    string str = "pwwkew";
    int ret = s.ans1(str);
    cout << ret << endl;

}

int main(void){
    test1();
    test2();
    test3();

    return 0;
}